package com.xiyi.shouxin.view.pojo;

import java.math.BigDecimal;
import java.math.MathContext;
import java.math.RoundingMode;

import com.xiyi.shouxin.entity.user.Practice;

import lombok.Getter;
import lombok.Setter;

@Getter
@Setter
public class PracticeView extends Practice {
    private UserView user;
    
    /*
     * 平均深度
     */
    private Double depth;
    /*
     * 平均频率
     */
    private Double num;

    /*
     * 最大深度
     */
    private Double maxDepth;
    /*
     * 最小深度
     */
    private Double minDepth;
    /*
     * 最慢频率
     */
    private Double maxTime;
    /*
     * 最快频率
     */
    private Double minTime;
    /*
     * 频率达标
     */
    private Integer rateCount;
    /*
     * 频率过快
     */
    private Integer fastRateCount;
    /*
     * 频率过慢
     */
    private Integer slowRateCount;
    /*
     * 深度达标
     */
    private Integer depthCount;
    /*
     * 深度过深
     */
    private Integer heavyDepthCount;
    /*
     * 深度过浅
     */
    private Integer slowDepthCount;
    /*
     * '过轻','合格','太重','太慢','太快','过轻过慢','过轻过快','过重过慢','过重过快'
     */
    private String qualified;

    /**
     * 排名
     */
    private Integer rank;

     /**
     * 最高总数
     */
    private Integer maxTotal;

    public PracticeView(Practice practice, UserView user) {
        if (practice != null) {
            this.setId(practice.getId());
            this.setUid(practice.getUid());
            this.setAdminId(practice.getAdminId());
            this.setDeviceId(practice.getDeviceId());
            this.setQualifiedQuantity(practice.getQualifiedQuantity());
            this.setTotal(practice.getTotal());
            this.setIsDelete(practice.getIsDelete());
            this.setNotReset(practice.getNotReset());
            this.setTime(practice.getTime());
            this.setCreatedAt(practice.getCreatedAt());
            this.setIsCheck(practice.getIsCheck());
            BigDecimal d1 = new
            BigDecimal(practice.getPassRate().toString());
            BigDecimal d2 = new BigDecimal("100");
            this.setPassRate(d1.multiply(d2,new MathContext(4,RoundingMode.HALF_UP)).doubleValue());
        }
        this.user = user;
    }
}
